﻿using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Traceability.APP.Application.Command.Breeds;
using Traceability.APP.Application.Command.Pictures;
using Traceability.Damoin;
using Traceability.ErrorCode;

namespace Traceability.APP.Controllers
{ /// <summary>
  /// 照片
  /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class PriceController : ControllerBase
    {
        private readonly IMediator mediator;

        public PriceController(IMediator mediator)
        {
            this.mediator = mediator;
        }

        /// <summary>
        /// 图片新增
        /// </summary>
        /// <param name="request">实体</param>
        /// <returns>返回任务</returns>
        [HttpPost]
        public async Task<APIResult<int>> AddPicture(AddpictureCommand request)
        {
            return await mediator.Send(request);
        }
        /// <summary>
        /// 图片删除
        /// </summary>
        /// <param name="Id">实体</param>
        /// <returns>返回任务</returns>
        [HttpPost]
        public async Task<APIResult<int>> DeletePicture(int Id)
        {
            DeletepictureCommand request = new DeletepictureCommand()
            {
                Id = Id
            };
            return await mediator.Send(request);
        }
        /// <summary>
        /// 获取图片表
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public async Task<APIResult<List<Picture>>> GetImmunity([FromQuery] GetpictureCommand command)
        {
            try
            {
                var result = await mediator.Send(command);
                return result;
            }
            catch (Exception ex)
            {

                throw;
            }
        }
        /// <summary>
        /// 图片修改
        /// </summary>
        /// <param name="request">实体</param>
        /// <returns>返回任务</returns>
        [HttpPut]
        public async Task<APIResult<int>> UpdatePicture(UpdatepictureCommand request)
        {
            return await mediator.Send(request);
        }
    }
}
